#include "stdafx.h"
#include "main.h"

Scene *scene;

int Glut_w = 800;
int Glut_h = 600;

void display() 
{
	glClearColor(1.0, 1, 1, 0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	scene->render();

	glutReshapeWindow(Glut_w, Glut_h);
	glFlush();
}

void init()
{
	ShaderManager::init();

	scene = new Scene();
	scene->loadScene();
}

void reshape(int width, int height)
{
	Glut_w = width;
	Glut_h = height;
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(90, Glut_w/(float)Glut_h,0.1, 99);
	glViewport(0, 0, Glut_w, Glut_h);
}  

int main(int argc, char* argv[]) 
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
	glutCreateWindow("3D Application");
	   
	glewInit() ; 
	glutReshapeWindow(Glut_w, Glut_h);
	
	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutMotionFunc(mousedrag) ;
	glutMouseFunc(mouse);
	glutMouseWheelFunc(mouseWheel);
	glutReshapeFunc(reshape);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc (GL_LESS) ;

	init();

	glutMainLoop();
	return 0;
}